﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:MVVMFramework.View">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/MVVMFramework.View;component/Themes/Colors.xaml"/>
        <ResourceDictionary Source="/MVVMFramework.View;component/Themes/Common.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="NumericUpDownStyle" TargetType="Control">
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
        <Setter Property="HorizontalContentAlignment" Value="Right" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Control">
                    <local:ButtonSpinner x:Name="Spinner"
                                    IsTabStop="False"
                                    Background="{TemplateBinding Background}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    AllowSpin="{Binding AllowSpin, RelativeSource={RelativeSource TemplatedParent}}"
                                    ShowButtonSpinner="{Binding ShowButtonSpinner, RelativeSource={RelativeSource TemplatedParent}}">

                        <AdornerDecorator Grid.Column="0" VerticalAlignment="Center" >
                            <TextBox x:Name="TextBox" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" Style="{x:Null}"
                                         BorderThickness="0"
                                          Background="Transparent"
                                          ContextMenu="{TemplateBinding ContextMenu}"
                                          FontFamily="{TemplateBinding FontFamily}" 
                                          FontSize="{TemplateBinding FontSize}" 
                                          FontStretch="{TemplateBinding FontStretch}"
                                          FontStyle="{TemplateBinding FontStyle}" 
                                          FontWeight="{TemplateBinding FontWeight}" 
                                          Foreground="{TemplateBinding Foreground}" 
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          MinWidth="20"
                                          AcceptsReturn="False"
                                          Padding="0"
                                          TextAlignment="{Binding TextAlignment, RelativeSource={RelativeSource TemplatedParent}}"
                                          TextWrapping="NoWrap" 
                                          TabIndex="{TemplateBinding TabIndex}"
                                          Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}"
                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}">
                                <local:WatermarkService.Watermark>
                                    <TextBlock Text="{Binding Watermark, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </local:WatermarkService.Watermark>
                            </TextBox>
                        </AdornerDecorator>
                        
                    </local:ButtonSpinner>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- =============================================================================== -->
    <!-- DecimalUpDown                                                                   -->
    <!-- =============================================================================== -->

    <Style TargetType="local:DecimalUpDown" BasedOn="{StaticResource NumericUpDownStyle}">
        <Setter Property="TextAlignment" Value="Right" />
    </Style>

    <!-- =============================================================================== -->
    <!-- IntegerUpDown                                                                   -->
    <!-- =============================================================================== -->

    <Style TargetType="{x:Type local:IntegerUpDown}" BasedOn="{StaticResource NumericUpDownStyle}">
        <Setter Property="TextAlignment" Value="Right" />
    </Style>

</ResourceDictionary>